(function(){"use strict";BX.namespace("BX.Landing");BX.Landing.SiteCookies=function(e){this.bbFormAjaxPath=e.bbFormAjaxPath;this.idAgreementNew=e.idAgreementNew?BX(e.idAgreementNew):null;this.classNameAgreementBlock=e.classNameAgreementBlock||"landing-agreement-block";this.classNameAgreementDelete=e.classNameAgreementDelete||"landing-agreement-delete";this.classNameAgreementAdd=e.classNameAgreementAdd||"landing-agreement-add";this.classNameEditIcon=e.classNameEditIcon||"landing-agreement-edit";this.classCloseWarningIcon=e.classCloseWarningIcon||"landing-agreement-warning-close";this.classInputBlock=e.classInputBlock||"landing-agreement-input-block";this.classEditTitle=e.classEditTitle||"landing-agreement-cookies-name-edit";this.classBlockAreaShow=e.classBlockAreaShow||"landing-agreement-block-inner-show";this.inputBlocks=document.querySelectorAll(".landing-agreement-input");this.messages=e.messages||{};this.input=null;this.binding();this.bindEvents()};BX.Landing.SiteCookies.prototype={binding:function(){var e=[].slice.call(document.querySelectorAll("."+this.classNameAgreementDelete));e.map(function(e){if(!BX.hasClass(e,"landing-binding")){BX.addClass(e,"landing-binding");BX.bind(e,"click",function(t){BX.UI.Dialogs.MessageBox.confirm(this.messages.removeAlertText,this.messages.removeAlertTitle,function(t){this.removeAgreement(e);t.close()}.bind(this))}.bind(this))}}.bind(this));var t=document.querySelector("."+this.classNameAgreementAdd);if(t){if(!BX.hasClass(t,"landing-binding")){BX.addClass(t,"landing-binding");BX.bind(t,"click",function(e){this.addNewAgreement(t)}.bind(this))}}},bindEvents:function(){[].forEach.call(this.inputBlocks,function(e){e.addEventListener("click",BX.delegate(this.toggleSection,this));var t=e.parentNode.nextElementSibling;if(t.classList.contains(this.classBlockAreaShow)){setTimeout(function(){t.style.height=t.children[0].offsetHeight+"px"},1200)}}.bind(this));var e=document.querySelectorAll("."+this.classNameEditIcon);[].forEach.call(e,function(e){e.addEventListener("click",this.showInput.bind(this))}.bind(this));var t=document.getElementById(this.classCloseWarningIcon);if(t){t.addEventListener("click",this.closeWarning.bind(this))}},showInput:function(e){this.parent=e.currentTarget.parentNode;this.input=e.currentTarget.previousElementSibling;this.input.value=this.input.previousElementSibling.textContent;this.input.focus();this.parent.classList.add(this.classEditTitle);BX.bind(document,"mousedown",this.hideInput.bind(this))},hideInput:function(e){if(e.target===this.input){return}this.input.previousElementSibling.textContent=this.input.value;this.input.setAttribute("value",this.input.previousElementSibling.textContent);this.parent.classList.remove(this.classEditTitle);BX.unbind(document,"mousedown",this.hideInput)},closeWarning:function(e){var t=e.currentTarget.closest(".ui-alert");t.remove()},toggleSection:function(e){var t=e.currentTarget.parentNode.nextElementSibling;var i=e.currentTarget;if(t.classList.contains(this.classBlockAreaShow)){i.checked=false;t.style.height=0;t.classList.remove(this.classBlockAreaShow)}else{i.checked=true;t.style.height=t.children[0].offsetHeight+"px";t.classList.add(this.classBlockAreaShow)}},addNewAgreement:function(e){if(!this.bbFormAjaxPath){return}BX.ajax({url:this.bbFormAjaxPath,method:"GET",onsuccess:function(e){if(this.idAgreementNew){var t=BX.create("div",{html:e});this.idAgreementNew.append(t)}this.binding()}.bind(this)})},removeAgreement:function(e){var t=e.closest("."+this.classNameAgreementBlock);while(t){if(BX.hasClass(t,this.classNameAgreementBlock)){BX.remove(t);break}}}}})();
//# sourceMappingURL=script.map.js